<?php

namespace App\Http\Controllers;

use App\Product;
use Illuminate\Http\Request;

class ReceiveController extends Controller
{
    public function tck(Request $request)
    {
        $crypt = $request->get('TCK');
        if ($crypt) {
            $array = str2arr_de($crypt);
            if ($array) {
                if ($array['ee'] != '0000') {
                    $product = Product::firstOrCreate(['ie' => $array['ie']]);
                    $product->createWarning($array['ee']);
                }
            }
        }
        return response('ok');
    }

    public function dat(Request $request)
    {
        $crypt = $request->get('DAT');
        if ($crypt) {
            $array = str2arr_de($crypt);
            if ($array) {
                $product = Product::firstOrCreate(['ie' => $array['ie']]);
                $product->createRecord($array);
            }
        }
        return response('ok');
    }

}
